package org.lightpersist.hibernate;

import org.hibernate.Session;

import com.google.inject.Provider;
/**
 * 
 * @author GL
 *
 */
public abstract class SessionProvider implements Provider<Session>{

	private static volatile SessionProvider instance;
	
	public SessionProvider() {
		instance=this;
	}
	
	public static SessionProvider getInstance(){
		return instance;
	}
	
	public boolean isTransactionActive(){
		Session s = get();
		return s!=null & s.getTransaction().isActive();
	}
	
	public abstract Session get();
	
	public void releaseSession(){
	}
	
}
